/**
 * Created by hcadmin on 16/4/11.
 */
define([
    "jquery",
    "IO",
    "bootbox"
], function ($, IO, bootbox) {

    var year_1 = 1;
    var year_2 = 2;
    var year_3 = 3;

    var activity_mid = localStorage.getItem("activity_mid");

    $("#btnSave1").click(function(){
        var group_mid=$("#selectgroup1 option:selected").attr("data-id");
        var ExtraBonus=$("#selectExtraBonus1 option:selected").attr("data-id");
        var money= $('.money1').text();
        gettable(year_1,group_mid,ExtraBonus,money);

    });
    $("#btnSave2").click(function(){
        var group_mid=$("#selectgroup2 option:selected").attr("data-id");
        var ExtraBonus=$("#selectExtraBonus2 option:selected").attr("data-id");
        var money= $('.money2').text();
        gettable(year_2,group_mid,ExtraBonus,money);

    });
    $("#btnSave3").click(function(){
        var group_mid=$("#selectgroup3 option:selected").attr("data-id");
        var ExtraBonus=$("#selectExtraBonus3 option:selected").attr("data-id");
        var money= $('.money3').text();
        gettable(year_3,group_mid,ExtraBonus,money);
    });

    function gettable(year_id,group_mid,extraBonuses_mid,money){
        var parmas={};
        parmas.year_id=year_id;
        parmas.extraBonuses_mid=extraBonuses_mid;
        parmas.group_mid=group_mid;
        parmas.money=money;
        parmas.activity_mid=activity_mid;
        if(group_mid=="undefined"){
            alert("请选择公司");
            return;
        }

        if(money==""||isNaN(parmas.money)){
            alert("请输入奖惩金额");
            return;
        }
        IO.post('/shapan/api/ExtraBonusAdd',parmas,function(d){
            alert(d.msg);
        })
    }
});